

//
//  ClassMamagerCell.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/30.
//  Copyright © 2016年 Gcx. All rights reserved.
//

#import "ClassMamagerCell.h"
#import "ClassManagerModel.h"
#import "MMLabel.h"
@implementation ClassMamagerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _contentLabel = [[MMLabel alloc]initWithFrame:CGRectMake(ScaleSize(42), ScaleSize(48), SIZEWIDTH - ScaleSize(84), 0)];
        _contentLabel.numberOfLines = 0;
        _contentLabel.font = NormalFont(42);
        _contentLabel.textColor  = Color333333;
        [self.contentView addSubview:_contentLabel];
        
        
        _numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScaleSize(42), CGRectGetMaxY(_contentLabel.frame)+ScaleSize(39), SIZEWIDTH - ScaleSize(84), 20)];
        _numberLabel.font = NormalFont(39);
        _numberLabel.textColor  = Color999999;
        [self.contentView addSubview:_numberLabel];

    }
    
    return  self;
}

+ (ClassMamagerCell *)cellWithTab:(UITableView *)tableView{

    static NSString *ident = @"cell";
    
    ClassMamagerCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
    
    if (!cell) {
        
        cell = [[ClassMamagerCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
    }
    return cell;
}

- (void)setMyModel:(ClassManagerModel *)myModel{

    _myModel = myModel;
    
    _contentLabel.text = [NSString stringWithFormat:@"%@  (%@)", myModel.kcmc, myModel.skxq];
    
    _contentLabel.keyWord =[NSString stringWithFormat:@"(%@)", myModel.skxq];
    
    _contentLabel.keyWordColor = Color999999;
    
    CGRect size = [self stringRectWithSize:CGSizeMake(SIZEWIDTH-ScaleSize(84), 0) fontSize:42 withString:_contentLabel.text];
    
    _contentLabel.frame = CGRectMake(ScaleSize(42), ScaleSize(48), SIZEWIDTH - ScaleSize(84), size.size.height);

    _numberLabel.text = [NSString stringWithFormat:@"共%@名学生", myModel.xsrs];

    _numberLabel.frame = CGRectMake(ScaleSize(42), CGRectGetMaxY(_contentLabel.frame)+ScaleSize(39), SIZEWIDTH - ScaleSize(84), 20);
}

- (CGRect)stringRectWithSize:(CGSize)size fontSize:(CGFloat)font withString:(NSString *)string
{
    /**
     字符串进行自适应的方法
     
     第一个参数:是进行自适应的尺寸
     第二个参数:样式(模式)
     第三个参数:一些字符串(字体)的属性
     第四个参数:忽略
     */
    CGRect rect =  [string boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: NormalFont(font)} context:nil];
    
    return  rect;
}

@end
